package com.woniuxy.creditsystem.common.mapper;

import com.woniuxy.creditsystem.common.bean.FinanceInfo;
import com.woniuxy.creditsystem.statisticsmag.page.PageRequest;
import org.apache.ibatis.annotations.*;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

/**
 * 财务统计mapper
 *
 * @author 刘川
 */
@Mapper
public interface FinanceMapper {
    /**
     * 查询所有财务统计信息
     *
     * @return
     */
    @Results({
            @Result(id = true, property = "id", column = "id", javaType = Long.class),
            @Result(property = "lendingDate", column = "lending_date", javaType = Date.class),
            @Result(property = "loanOrderNums", column = "loan_order_nums", javaType = Long.class),
            @Result(property = "loanOrderAmount", column = "loan_order_amount", javaType = BigDecimal.class),
            @Result(property = "loanAmount", column = "loan_amount", javaType = BigDecimal.class),
            @Result(property = "returnOrderNums", column = "return_order_nums", javaType = Long.class),
            @Result(property = "returnBillNums", column = "return_bill_nums", javaType = Long.class),
            @Result(property = "returnAmount", column = "return_amount", javaType = BigDecimal.class),
            @Result(property = "returnPrincipal", column = "return_principal", javaType = BigDecimal.class),
            @Result(property = "returnInterest", column = "return_interest", javaType = BigDecimal.class),
            @Result(property = "returnPenalty", column = "return_penalty", javaType = BigDecimal.class),
            @Result(property = "waitOrderNums", column = "wait_order_nums", javaType = Long.class),
            @Result(property = "waitBillNums", column = "wait_bill_nums", javaType = Long.class),
            @Result(property = "waitAmount", column = "wait_amount", javaType = BigDecimal.class),
            @Result(property = "waitPrincipal", column = "wait_principal", javaType = BigDecimal.class),
            @Result(property = "waitInterest", column = "wait_interest", javaType = BigDecimal.class),
            @Result(property = "waitPenalty", column = "wait_penalty", javaType = BigDecimal.class),
            @Result(property = "waitService", column = "wait_service", javaType = BigDecimal.class),
            @Result(property = "overdueOrderNums", column = "overdue_order_nums", javaType = Long.class),
            @Result(property = "overduePrincipal", column = "overdue_principal", javaType = BigDecimal.class)
    })
    @Select("select * from finance_info")
    List<FinanceInfo> findAll();


    /**
     * 添加每日的财务统计信息
     *
     * @param financeInfo
     * @return 受影响的行数
     */
    @Insert("insert into finance_info (overdue_order_nums,loan_order_amount) values(#{f.overdueOrderNums},#{f.loanOrderAmount})")
    int saveFinance(@Param("f") FinanceInfo financeInfo);


    /**
     * 分页查询
     * @param financeInfo
     * @return
     */
    List<FinanceInfo> findAllByParams(@Param("p") PageRequest request, @Param("f") FinanceInfo financeInfo);




    /**
     * 查询近一个月待收数据
     * @return
     */

    List<FinanceInfo> findMonDataDs();


    /**
     * 查询近一个月回款数据
     * @return
     */
    List<FinanceInfo> findMonDataHk();



    /**
     * 查询近一个月逾期数据
     * @return
     */
    List<FinanceInfo> findMonDataYq();
}
